package com.dishdex.menuhub.module.mapper;

import com.dishdex.menuhub.module.entity.${entity};
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ${entity}Mapper{

    @Select("select * from ${entity?uncap_first} where id = <#noparse>#{id}</#noparse> and is_deleted=0")
    ${entity} get${entity}ById(@Param("id") Long id);

    @Select("select * from ${entity?uncap_first} where id = <#noparse>#{id}</#noparse>")
    ${entity} extract${entity}ById(@Param("id") Long id);

    Long insert${entity}(${entity} ${entity?uncap_first});

    Long update${entity}(${entity} ${entity?uncap_first});

    @Update("update ${entity?uncap_first} set is_deleted=1 where id=<#noparse>#{id}</#noparse> and is_deleted=0")
    int delete${entity}(@Param("id") Long id);

    @Select("select * from ${entity?uncap_first} where is_deleted=0")
    List<${entity}> getAll${entity}();

}